package com.example.smartcity.ui.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.smartcity.R;

public class AllFunctionAdapter extends BaseAdapter {
    String[] titles;
    int[] icons;
    int resource;
    public  AllFunctionAdapter(String[] titles,int[] icons,int resource){
        this.icons = icons;
        this.titles = titles;
        this.resource = resource;
    }
    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(parent.getContext()).inflate(resource,parent,false);
        ImageView IV_topicFunctionIcon = view.findViewById(R.id.IV_topicFunctionIcon);
        TextView TV_topicFunctionTitle = view.findViewById(R.id.TV_topicFunctionTitle);
        IV_topicFunctionIcon.setImageResource(icons[position]);
        TV_topicFunctionTitle.setText(titles[position]);
        return view;
    }
}
